//
//  BookInfo.m
//  奇阅
//
//  Created by 奇阅科技 on 14-11-11.
//  Copyright (c) 2014年 奇阅科技. All rights reserved.
//

#import "BookInfo.h"
#import "Book.h"
@implementation BookInfo
+(NSString *)getTableName
{
    return @"BookInfo";
}
+(BookInfo *)getFromDict:(NSDictionary *)dict{
    BookInfo *book = [BookInfo new];
    book.book = [Book getFromDict:dict];
    book.articleid = book.book.articleid;
    book.sortname = [[dict objectForKey:@"sortname"] objectForKey:@"title"];
    book.price = [dict objectForKey:@"price"];
    book.bookAbout = [dict objectForKey:@"description"];
    book.last_chapter = [[dict objectForKey:@"lastup_text"] objectForKey:@"subhead"];
    book.finishflag = [[dict objectForKey:@"finishflag"] boolValue];
    book.isFavorites = [[dict objectForKey:@"is_collect"] boolValue];
    book.wordtotal = [dict objectForKey:@"wordtotal"];
    return book;
}
+(BookInfo *)getFromYiDongDict:(NSDictionary *)dict{
    BookInfo *book = [BookInfo new];
    book.book = [Book getFromYiDongDict:dict];
    book.articleid = book.book.articleid;
    book.sortname = [[dict objectForKey:@"sortname"] objectForKey:@"title"];
    book.price = [dict objectForKey:@"price"];
    book.bookAbout = [dict objectForKey:@"description"];
    book.last_chapter = [[dict objectForKey:@"lastup_text"] objectForKey:@"subhead"];
    book.finishflag = [[dict objectForKey:@"finishflag"] boolValue];
    book.isFavorites = [[dict objectForKey:@"is_collect"] boolValue];
    book.wordtotal = [dict objectForKey:@"wordtotal"];
    return book;
}
//更新 数据
-(void)upDateNew:(BookInfo *)newBook{
    self.sortname = newBook.sortname;
    self.price = newBook.price;
    self.bookAbout = newBook.bookAbout;
    [self.book upDateNew:newBook.book];
    self.last_chapter = newBook.last_chapter;
    self.finishflag = newBook.finishflag;
    self.wordtotal = newBook.wordtotal;
    self.isFavorites = newBook.isFavorites;
}
@end
